package tests.sf.model.fields;

import java.util.ArrayList;

import junit.framework.*;

import sf.model.fields.TypeRegexConverter;

public class TypeRegexConverterTest extends TestCase {

    public void testGetRegex() {
	assertEquals(".{3}", TypeRegexConverter.getRegex("char(3)"));
	assertEquals(".{0,20}", TypeRegexConverter.getRegex("varchar(20)"));
	assertEquals(TypeRegexConverter.getDatetimeRegex(), TypeRegexConverter
		.getRegex("datetime"));
	assertEquals("[-+]?\\d*", TypeRegexConverter.getRegex("int"));
	assertEquals("[+-]?\\d*(\\.\\d+){0,4}", TypeRegexConverter
		.getRegex("numeric(4)"));

    }

    public void testGetRegexForComposite() {
	ArrayList<String> types = new ArrayList<String>();
	types.add("char(4)");
	// types.add("datetime");
	types.add("numeric(4)");
	types.add("varchar(30)");

	assertEquals(".{4}-[+-]?\\d*(\\.\\d+){0,4}-.{0,30}", TypeRegexConverter
		.getRegexForComposite("-", types));
    }
}
